package com.yunji.storage.context;

import com.yunji.base.cache.BaseCache;
import com.yunji.common.utils.bean.BeanUtils;
import com.yunji.storage.domain.StorageRecordsDO;
import com.yunji.storage.vo.StorageRecordsVO;

import java.util.ArrayList;
import java.util.List;

public class StorageRecordConvert {

    public static List<StorageRecordsVO> domainToVO(List<StorageRecordsDO> list) {
        List<StorageRecordsVO> voList = new ArrayList<>();
        list.forEach(item -> voList.add(domainToVO(item)));
        return voList;
    }

    public static StorageRecordsVO domainToVO(StorageRecordsDO storageRecord) {
        StorageRecordsVO vo = new StorageRecordsVO();
        BeanUtils.clone(storageRecord, vo);
        vo.setBelongName(BaseCache.getBelongName(vo.getBelongId()));
        return vo;
    }

}
